package com.zzh.bc.log;

public class log {
    private static final int ELEMENTS_INDEX = 1;
    static String className;
    static String methodName;
    static int lineNumber;

    public static void d(String msg) {
        System.out.println(msg);
    }

    public static void e(String msg) {
        System.err.println(msg);
    }

    public static void info(CharSequence cs) {
        System.out.println(cs);
    }

    public static void info(Throwable cs) {
        if (cs == null) {
            return;
        }
        getMethodNames(cs.getStackTrace());
        System.out.println(className + ":" + methodName + ":" + lineNumber + " " + cs);
    }

    private static void getMethodNames(StackTraceElement[] sElements) {
        className = sElements[ELEMENTS_INDEX].getFileName();
        methodName = sElements[ELEMENTS_INDEX].getMethodName();
        lineNumber = sElements[ELEMENTS_INDEX].getLineNumber();
    }
}
